package org.zjvis.datascience.common.gis.GisUtils;

public class GisEncodingUtil {

	/**
	 * 根据dbf中的Language Driver ID获取文件编码格式
	 *
	 * @param languageDriverId 在文件头中，占一个字节，
	 * @return 文件的字符编码
	 */
	public static String convertDriverIdToEncodingString(byte languageDriverId) {
		int languageDriverIdIntValue = languageDriverId & 0xff;
		switch (languageDriverIdIntValue) {
			case 0x01:
			case 0x09:
			case 0x0B:
			case 0x0D:
			case 0x0F:
			case 0x11:
			case 0x15:
			case 0x18:
			case 0x19:
			case 0x1B:
				return "IBM437";
			case 0x02:
			case 0x0A:
			case 0x0E:
			case 0x10:
			case 0x12:
			case 0x14:
			case 0x16:
			case 0x1A:
			case 0x1D:
			case 0x25:
			case 0x37:
				return "ibm850";
			case 0x03:
			case 0x57:
			case 0x58:
			case 0x59:
				return "Windows-1252";
			case 0x04:
				return "macintosh";
			case 0x08:
			case 0x17:
			case 0x66:
				return "IBM865";
			case 0x13:
			case 0x7B:
				return "iso-2022-jp";
			case 0x1C:
			case 0x6C:
				return "IBM863";
			case 0x1F:
			case 0x22:
			case 0x23:
			case 0x40:
			case 0x64:
			case 0x87:
				return "ibm852";
			case 0x24:
				return "IBM860";
			case 0x26:
			case 0x65:
				return "cp866";
			case 0x4D:
			case 0x7A:
				return "GBK";
			case 0x4E:
			case 0x79:
				return "ks_c_5601-1987";
			case 0x4F:
			case 0x78:
				return "BIG5";
			case 0x50:
			case 0x7C:
				return "windows-874";
			case 0x67:
				return "ibm861";
			case 0x6A:
			case 0x86:
				return "ibm737";
			case 0x6B:
			case 0x88:
				return "ibm857";
			case 0x96:
				return "x-mac-cyrillic";
			case 0x97:
				return "x-mac-ce";
			case 0x98:
				return "x-mac-greek";
			case 0xC8:
				return "windows-1250";
			case 0xC9:
				return "windows-1251";
			case 0xCA:
				return "windows-1254";
			case 0xCB:
				return "windows-1253";
			case 0xCC:
				return "windows-1257";
			default:
				return null;
		}
	}
}
